package com.gitee.elf.core.data

import com.google.gson.*
import java.lang.reflect.Type


class DataFloat(var value: Float) : Data {

    override fun getValue(): Any {
        return value
    }
    override fun toString(): String {
        return value.toString()
    }


    override fun clone(): DataFloat {
        return DataFloat(value)
    }

    @SerializerType(DataFloat::class)
    class Serializer : JsonSerializer<DataFloat>, JsonDeserializer<DataFloat> {

        override fun serialize(src: DataFloat?, typeOfSrc: Type?, context: JsonSerializationContext?): JsonElement {
            return JsonPrimitive(src!!.value)
        }

        override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): DataFloat {
            return DataFloat(json!!.asFloat)
        }


    }
}